package com.broada.apm.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;

public class TradeErrorDetail {
	private String id;
	private Date timestamp;
	private String errorMessage;
	private List<NameAndValue> fields = new ArrayList<TradeErrorDetail.NameAndValue>();
	public TradeErrorDetail() {
		super();
	}
	
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Date getTimestamp() {
		return timestamp;
	}

	public void setTimestamp(Date timestamp) {
		this.timestamp = timestamp;
	}

	public String getErrorMessage() {
		return errorMessage;
	}

	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

	public List<NameAndValue> getFields() {
		return fields;
	}

	public void setFields(TreeMap<String, Object> data) {
		for (Entry<String,Object> entry : data.entrySet()) {
			this.fields.add(new NameAndValue(entry.getKey(), entry.getValue()));
		}
	}

	public static class NameAndValue {
		private String name;
		private Object value;

		public NameAndValue(String name, Object value) {
			super();
			this.name = name;
			this.value = value;
		}

		public NameAndValue() {
			super();
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public Object getValue() {
			return value;
		}

		public void setValue(Object value) {
			this.value = value;
		}

	}
}
